<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="keywords"  content="设置关键词..." />
    <meta name="description" content="设置描述..." />
    <meta name="author" content="DeathGhost" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <link rel="icon" href="images/icon/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <link  rel="stylesheet" type="text/css" href="BootStrap/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="layui-v2.5.7/layui/css/layui.css"/>
    <script src="layui-v2.5.7/layui/layui.js"></script>
    <script src="BootStrap/js/jquery.js"></script>
    <script src="BootStrap/js/bootstrap.js"></script>
</head>
<body>
<div class="page-wrap">
    <section class="page-hd">
        <header>
            <h2 class="title">维修人员信息表</h2>
        </header>
        <hr>
    </section>
    <div class="breadcrumb">
        <ul>
            <li><a >人员管理</a><i class="icon-angle-right"></i></li>
            <li><a >维修人员</a><i class="icon-angle-right"></i></li>
        </ul>
    </div>

</div>

<div class="page-wrap">

    <form id="myform" class="form-inline">
        人员姓名:<br>
        <i class="icon-search"></i>
        <input type="text" class="form-control" placeholder="请输入姓名" id="guGongName" style="width:350px" name="renYuanName">
        <br>

        加入时间:<br>
        <input type="text" class="form-control" placeholder="开始时间" style="width:280px"  name="kaishitime">至
        <input type="text" class="form-control" placeholder="结束时间" style="width:280px " name="jieshutime">
        <button type="button" class="btn btn-primary" name="Se">搜索</button>
        <button  class="btn btn-default" name="cl">清除</button><br>
        <br>
        <button type="button" class="btn btn-primary" name="zenjia" onclick="TianJian()">添加人员</button>
    </form>
</div>
<i class="layui-icon layui-icon-friends"></i>
<font size="4">总用户数:</font>
&nbsp;&nbsp;&nbsp;
<span id="user_count" style="font-size: 20px"></span>
<br/>
<div class="breadcrumb">
    <table class="table table-striped table-bordered table-hover" style="width: 100%;margin: 20px auto" >
        <thead>
        <tr>
            <th><input type="checkbox"/></th>
            <th>维修人姓名</th>
            <th>手机号</th>
            <th>负责医院</th>
            <th>电子邮箱</th>
            <th>加入时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="tbody">

        </tbody>
    </table>
    <ul class="pagination pull-right" id="page">

    </ul>
</div>
<!--增加模态框开始-->
<div class="modal fade" id="GuDongZengJia_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" >维修人员增加</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" style="width: 400px;margin: 0px auto" id="WeiXiu_add_Form" enctype="multipart/form-data" >
                    <div class="form-group">
                        <label class="col-lg-4 control-label">人员姓名：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="username" id="TUserName">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">人员电话：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="userphone" id="TUserphone">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">医院/科室：</label>
                        <div class="col-lg-8 ">

                            <select class="form-control"  required="qingshuru " placeholder="医院" name="userphone" id="TYiYuan">

                            </select>
                            <select class="form-control"  required="required" placeholder="科室" name="userphone" id="TKeShi">
                                <option ></option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">电子邮箱：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="useremail" id="Tuseremail">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">加入时间：</label>
                        <div class="col-lg-8 ">
                            <input type="date" class="form-control"  required="required" name="userregistrationtime" id="Tuserregistrationtime">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-4 control-label">人员密码：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="userpassword" id="Tuserpassword">
                        </div>
                    </div>


                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal" >关闭</button>
                <button type="button" class="btn btn-primary" id="Goods_Add_save_btn" onclick=BaoCunGuDong()>保存</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!--增加模态框结结束-->
<!--编辑模态框开始-->
<div class="modal fade" id="GuDongBianJi_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">维修人员编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" style="width: 400px;margin: 0px auto" id="bianji_add_form" enctype="multipart/form-data" >
                    <div class="form-group">
                        <label class="col-lg-4 control-label">人员姓名：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="username" id="username">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">人员电话：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="userphone" id="userphone">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">医院/科室：</label>
                        <div class="col-lg-8 ">
                             <select class="form-control"  required="required " placeholder="医院" name="userphone" id="BYiYuan">

                             </select>
                            <select  class="form-control"  required="required" placeholder="科室" name="userphone" id="BKeShi">

                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-4 control-label">电子邮箱：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="useremail" id="useremail">
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="col-lg-4 control-label">密码：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="userpassword" id="userpassword">
                        </div>
                    </div>
                    <input type="hidden" name="userid" id="userid">

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal" >关闭</button>
                <button type="button" class="btn btn-primary"  onclick=BianJiBaoCun()>保存</button>
            </div>

        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!--编辑模态框结束-->
<!--删除模态框开始-->
<div class="modal fade" id="delGuDong_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <h1 style="text-align: center">你确认要删除吗？</h1>
                <h2 style="text-align: center">删除后该维修人员记录全部删除哦</h2>
            </div>
            <input type="hidden" id="uid">
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="delGuDong" onclick="delGudong()" >删除</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!--删除模态框结束-->
<script>
    getAll(1);
    function getAll(pageNumber) {
        var renYuanName=$(":input[name=renYuanName]").val();
        var kaishitime=$(":text[name=kaishitime]").val();
        var jieshutime=$(":text[name=jieshutime]").val();

        $.ajax({
            url:'/yonghu/getAllWeiXiu',
            type:'post',
            data:{"renYuanName":renYuanName,"kaishitime":kaishitime,"jieshutime":jieshutime,"pageNumber":pageNumber,"pageSize":null,},
            success:function (data) {
                if(data.result==true){
                    var str="";
                    for (var i = 0; i < data.weixiu.length; i++) {
                        str+="<tr class='cen'>";
                        str+= "<td><input type='checkbox'/></td>";
                        str+="<td >"+data.weixiu[i].username+"</td>";
                        str+="<td>"+data.weixiu[i].userphone+"</td>";
                        str+="<td>"+(data.yiyuanname[i].hospitalinfoname)+""+(data.keshiname[i].departmentname)+"</td>";
                        str+="<td>"+data.weixiu[i].useremail+"</td>";
                        str+="<td>"+data.weixiu[i].userregistrationtime+"</td>";
                        str+="<td>";
                        str+="<input type='hidden' name='userId' value='"+data.weixiu[i].userid+"'>";
                        str+="<a title='编辑' class='mr-5' onclick=BianJi("+data.weixiu[i].userid+")>编辑</a>";
                        str+= " <a title='详情' class='mr-5' onclick='tiaozhuan("+data.weixiu[i].userid+")'>详情</a>";
                        str+= " <a  name='del' onclick='del("+data.weixiu[i].userid+")'> 删除</a>";
                        str+="</td></tr>";
                    }
                    $("#tbody").html(str);
                    var page="";
                    page+='<li class="'+(data.page.pageNum==1?'disabled':'')+'"><a onclick="getAll('+data.page.prePage+')" >上一页</a></li>';
                    for (var i =1;i<=data.page.pages ; i++) {
                        page+=' <li class="'+(data.page.pageNum==i?'active':'')+'"><a onclick="getAll('+i+')">'+i+'<span class="sr-only"></span></a></li>';
                    }
                    page+=' <li ><a onclick="getAll('+data.page.nextPage+')" >下一页</a></li>';
                    $("#page").html(page);
                    $("#user_count").html(data.page.total);
                }


            }
        });

    }

    // 根据姓名查询
    se();
    function se() {
        $(":button[name=Se]").click(function (){
            getAll(1);
        });

    }
    function cl() {
        $(":button[name=cl]").click(function (){
            $("#myform")[0].reset();
            getAll(1);
        });
    }

    //删除弹出模态框

    function del(id){
        $("#uid").val(id);
        $("#delGuDong_modal").modal("show");
    }
    //确认删除删除模态框

    function delGudong() {
        var userId=$("#uid").val(id);
            $.ajax({
                type:'post',
                url:'/yonghu/delWeiXiu',
                data:{"userId":userId},
                success:function (data){
                    $("#delGuDong_modal").modal("hide");
                    getAll(1);
                }
            });

    }
    //增加模态框弹出
    function TianJian(){
       //清空表单
        $("#WeiXiu_add_Form")[0].reset();
        $.ajax({
            url:'/yonghu/yiyuankeshiliebiao',
            type:'post',
            success:function (data){
                stry="";

                stry+="<option>--选择医院--</option>"
                for (var i = 0; i < data.hos.length; i++) {
                    stry+="<option value='"+data.hos[i].hospitalinfoid+"'>"+data.hos[i].hospitalinfoname+"</option>";
                }
                $("#TYiYuan").html(stry);
                strk="";
                strk+="<option>--选择科室--</option>"
                for (var i = 0; i <data.hosd.length ; i++) {
                    strk+="<option value='"+data.hosd[i].departmentid+"'>"+data.hosd[i].departmentname+"</option>";
                }
                $("#TKeShi").html(strk);
            }
        })


        $("#GuDongZengJia_modal").modal("show");
    }
    //信息保存模态框关闭
    function  BaoCunGuDong(){
        $.ajax({
            url:'/yonghu/TianJiaWeiXiu',
            type:'post',
            data:{"TUserName":$("#TUserName").val(),"TUserphone":$("#TUserphone").val(),"TYiYuan":$("#TYiYuan").val(),"TKeShi":$("#TKeShi").val(),"Tuseremail":$("#Tuseremail").val(),"Tuserregistrationtime":$("#Tuserregistrationtime").val(),"Tuserpassword":$("#Tuserpassword").val()},
            success:function (data){
                $("#GuDongZengJia_modal").modal("hide");
                getAll(1);
            }
        });
    }
    /*
       编辑模态框弹出
    * */
    function BianJi(userId){

        $.ajax({
            url:'/yonghu/BianJiWeiXiu',
            type:'post',
            data:{"userId":userId},
            success:function (data){

                stry="";
                for (var i = 0; i < data.hos.length; i++) {
                    if(data.hos[i].hospitalinfoname==data.sesHospitalinfos[0].hospitalinfoname){
                        stry+="<option value='"+data.hos[i].hospitalinfoid+"' selected='selected'>"+data.hos[i].hospitalinfoname+"</option>";
                    }else {
                        stry+="<option value='"+data.hos[i].hospitalinfoid+"' >"+data.hos[i].hospitalinfoname+"</option>";
                    }
                }
                $("#BYiYuan").html(stry);
                strk="";
                for (var i = 0; i <data.hosd.length ; i++) {
                    if(data.hosd[i].departmentname==data.sesHospitalinfoDepartments[0].departmentname){
                        strk+="<option value='"+data.hosd[i].departmentid+"' selected='selected'>"+data.hosd[i].departmentname+"</option>";
                    }else{
                        strk+="<option value='"+data.hosd[i].departmentid+"' >"+data.hosd[i].departmentname+"</option>";
                    }                }
                $("#BKeShi").html(strk);
                $("#GuDongBianJi_modal").modal("show");
                $("#username").val(data.sesUser.username);
                $("#userphone").val(data.sesUser.userphone);
                //data.sesHospitalinfos[].hospitalinfoname
                //data.sesHospitalinfoDepartments[0].departmentname
                // $("#BYiYuan").val(data.sesHospitalinfos[].hospitalinfoname);
                // $("#BKeShi").val(data.sesHospitalinfoDepartments[0].departmentname);
                $("#useremail").val(data.sesUser.useremail);
                $("#userpassword").val(data.sesUser.userpassword);
                $("#userid").val(data.sesUser.userid);

            }
        });
    }
    /*
    * 编辑股东保存
    * */
    function  BianJiBaoCun(){
        $.ajax({
            url:'/yonghu/BianJiWeiXiuBaoCun',
            type:'post',
            data:{"username":$("#username").val(),"userphone":$("#userphone").val(),"BYiYuan":$("#BYiYuan").val(),"BKeShi":$("#BKeShi").val(),"useremail":$("#useremail").val(),"userpassword":$("#userpassword").val(),"userid":$("#userid").val(),},
            success:function (data){
                $("#GuDongBianJi_modal").modal("hide");
                getAll(1);
            }
        });
    }

    /**
     * 跳转详情页面
     */
    function tiaozhuan(userId){

        window.localStorage.setItem("userid",userId);
        location.href="WeiXiuRenYuanXiangQing.html";
}


</script>
</body>
</html>